//
// Created by guanzhe on 16/1/3.
// Copyright (c) 2016 BMProject. All rights reserved.
//

#import "NumPoolCell.h"
#import "DataModel.h"
#import "NSDate+Utils.h"
#import "UIColor+Extension.h"

@interface NumPoolCell (){
    MsgModel *_model;
}

@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UILabel *numLabel;
@property (weak, nonatomic) IBOutlet UILabel *cardNumLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@end

@implementation NumPoolCell {

}

- (void)setCellInfo:(NSArray *)infoArr andPosition:(NSInteger)position {
    [super setCellInfo:infoArr andPosition:position];
    _model = [infoArr objectAtIndex:position];
    NumPoolModel *numPoolModel = [infoArr objectAtIndex:position];
    self.bgView.layer.cornerRadius = 5.0;
    self.bgView.layer.masksToBounds = YES;

    self.numLabel.text = [@"渠道编码:" stringByAppendingString:[NSString ignoreEmptyStr:numPoolModel.servicer]];

    NSMutableAttributedString *mobileString;
    mobileString = [[NSMutableAttributedString alloc] initWithString:[@"卡号:" stringByAppendingString:[NSString ignoreEmptyStr:numPoolModel.mobile]]];
    [mobileString addAttribute:NSForegroundColorAttributeName value:[UIColor hexValue:0x333333] range:NSMakeRange(3, numPoolModel.mobile.length)];
    self.cardNumLabel.attributedText = mobileString;

    NSMutableAttributedString *timeString;
    NSString *time = [[NSDate dateWithString:numPoolModel.createTime formatString:@"yyyyMMddHHmmss"] formatStringWithFormat:@"yyyy-MM-dd"];
    timeString = [[NSMutableAttributedString alloc] initWithString:[@"时间:" stringByAppendingString:[NSString ignoreEmptyStr:time]]];
    [timeString addAttribute:NSForegroundColorAttributeName value:[UIColor hexValue:0x333333] range:NSMakeRange(3, time.length)];
    self.timeLabel.attributedText = timeString;
}

- (IBAction)editAction:(id)sender {
    [self.delegate clickActionWithData:_model AndType:@"repair"];
}
- (IBAction)deleteAction:(id)sender {
    [self.delegate clickActionWithData:_model AndType:@"delete"];
}

@end